package record;

import util.HashedPassword;

/**
 * A class that represents the information needed for a user that uses the GeoExplorer and has an account.
 * @author Sean Freitag
 * @author Jacob Freemyer
 * @author Stephan Jossie
 */
@SuppressWarnings("serial")
public class UserRecord implements Record {
	/**
	 * First name
	 */
	private String firstName;
	
	/**
	 * Last name
	 */
	private String lastName;
	
	/**
	 * Directory of projects
	 */
	private Directory projectRecords;
	
	/**
	 * Email Address (Identifier) for user
	 */
	private String emailAddress;
	
	/**
	 * Password
	 */
	private HashedPassword password;
	
	/**
	 * Credit Card Number
	 */
	private String creditCardNumber;
	
	/**
	 * Credit Card Security Number
	 */
	private String creditCardSecurityNum;
	
	/**
	 * Credit Card Brand
	 */
	private String creditCardBrand;
	
	/**
	 * Creates an instance of a UserRecord that holds all of the information about the user
	 * @param firstName 
	 * @param lastName 
	 * @param emailAddress 
	 * @param password 
	 * @param creditCardNumber 
	 * @param creditCardSecurityNum 
	 * @param creditCardBrand 
	 * @param request
	 * 		The request sent from the server to get the data needed to create a user record.
	 */
	public UserRecord(String firstName, String lastName, String emailAddress, HashedPassword password, String creditCardNumber,
					  String creditCardSecurityNum, String creditCardBrand){
		this.firstName = firstName;
		this.lastName = lastName;
		this.projectRecords = null;
		this.emailAddress = emailAddress;
		this.password = password;
		this.creditCardNumber = creditCardNumber;
		this.creditCardSecurityNum = creditCardSecurityNum;
		this.creditCardBrand = creditCardBrand;
	}
	
	/**
	 * Getter to get a hashed version of the password
	 * @return
	 * 		A hashed version of the password for security
	 */
	public HashedPassword getPassword() {
		return password;
	}

	/**
	 * Getter to get the first name of the user
	 * @return
	 * 		Users first name
	 */
	public String getFirstName() {
		return firstName;
	}

	/**
	 * Getter to get the last name of the user
	 * @return
	 * 		Users last name
	 */
	public String getLastName() {
		return lastName;
	}

	/**
	 * Getter to get all the projects the user has in their account
	 * @return
	 * 		The root Directory to all the projects for the user
	 */
	public Directory getProjectRecords() {
		return projectRecords;
	}

	/**
	 * Getter to get the email address of the user
	 * @return
	 * 		Users email address
	 */
	public String getEmailAddress() {
		return emailAddress;
	}
	
	/**
	 * Getter to get the credit card number of the user
	 * @return
	 * 		Users credit card number
	 */
	public String getCreditCardNumber()
	{
		return creditCardNumber;
	}
	
	/**
	 * Changes the password of the user record
	 * @param pPassword
	 * The new password
	 */
	public void changePassword(HashedPassword pPassword)
	{
		password = pPassword;
	}
	
	/**
	 * Getter to get the credit card security code of the users card
	 * @return
	 * 		Users credit card security code
	 */
	public String getCreditCardSecurityNumber()
	{
		return creditCardSecurityNum;
	}
	
	/**
	 * Getter to get the brand or type of credit card. Visa,Mastercard, ect.
	 * @return
	 * 		Users credit card brand
	 */
	public String getCreditCardBrand()
	{
		return creditCardBrand;
	}
	

	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserRecord other = (UserRecord) obj;
		if (emailAddress == null) {
			if (other.emailAddress != null)
				return false;
		} else if (!emailAddress.equals(other.emailAddress))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (projectRecords == null) {
			if (other.projectRecords != null)
				return false;
		} else if (!projectRecords.equals(other.projectRecords))
			return false;
		return true;
	}
	
}
